<?php
declare (strict_types=1);

namespace app\api\controller;

use app\common\model\User;
use app\common\tool\Result;
use think\exception\ValidateException;
use think\Response;

class Register extends Base
{
    public function index(): Response
    {
        $param = $this->request->post();
        try {
            $this->validate($param, 'Register');
        } catch (ValidateException $e) {
            return Result::fail($e->getError());
        }

        return Result::fastReturn(User::_save(['data' => $param], []));
    }
}